package com.fruit.service.recommend.impl;

import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fruit.mapper.goods.GoodsMapper;
import com.fruit.mapper.recommend.RecommendMapper;
import com.fruit.pojo.goods.RightConfig;
import com.fruit.pojo.recommend.Recommend;
import com.fruit.service.recommend.RecommendManager;


@Service
public class RecommendService implements RecommendManager {
	
	
	@Autowired
	private RecommendMapper recommendMapper;
	
	@Autowired
	private GoodsMapper goodsMapper;

	/**
	 * 获取推荐位信息
	 * @param position 位置编号
	 * @return List<Recommend>
	 */
	public List<Recommend> findRecommendByPosition(Map<String, Object> pam) {
		// TODO Auto-generated method stub
		String classId = (String) pam.get("classId");
		if(StringUtils.isNotBlank(classId)){
			String type = (String) pam.get("type");
			RightConfig rightConfig = goodsMapper.getRightConfigByClassId(type, classId);
			pam.put("position", rightConfig.getCode() + "_list_banner");
		}
		return recommendMapper.findRecommendByPosition(pam);
	}

	/**
	 * 获取商品推荐位信息
	 * @param position 位置编号
	 * @return List<Recommend>
	 */
	public List<Recommend> getRecommendGoods(String position) {
		// TODO Auto-generated method stub
		return recommendMapper.getRecommendGoods(position);
	}

}
